package com.drools.rule.enums;

import java.util.Arrays;

public class UserAction {
    
    public enum UserActionEnum {

        LOGIN("LOGIN", "登录"),
        PAY("PAY","支付"),
        UNKNOWN("UNKNOWN", "未定义")
        ;

        String code;

        String desc;

        UserActionEnum(String code, String desc){
            this.code = code;
            this.desc = desc;
        }

        public UserActionEnum get(String actionCode){
            return Arrays.stream(UserActionEnum.values())
                    .filter(ua -> ua.code.equals(actionCode))
                    .findFirst()
                    .orElse(UNKNOWN);
        }
    }

    public enum UserLoginActionEnum {
        LOGIN_NUM("LOGIN_NUM", "登陆次数"),
        LOGIN_TIME("LOGIN_TIME","登陆时间"),
        UNKNOWN("UNKNOWN", "未定义")
        ;

        private String code;

        private String desc;

        UserLoginActionEnum(String code, String desc){
            this.code = code;
            this.desc = desc;
        }

        public static UserLoginActionEnum get(String actionCode){
            return Arrays.stream(UserLoginActionEnum.values())
                    .filter(ua -> ua.code.equals(actionCode))
                    .findFirst()
                    .orElse(UNKNOWN);
        }

        public String getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
    }

    public enum UserPayActionEnum {
        PAY_NUM("PAY_NUM", "支付次数"),
        PAY_AMOUNT_SINGLE("PAY_AMOUNT_SINGLE","单次支付金额"),
        PAY_AMOUNT_TOTAL("PAY_AMOUNT_TOTAL","累计支付金额"),
        UNKNOWN("UNKNOWN", "未定义")
        ;

        private String code;

        private String desc;

        UserPayActionEnum(String code, String desc){
            this.code = code;
            this.desc = desc;
        }

        public static UserPayActionEnum get(String actionCode){
            return Arrays.stream(UserPayActionEnum.values())
                    .filter(ua -> ua.code.equals(actionCode))
                    .findFirst()
                    .orElse(UNKNOWN);
        }

        public String getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
    }
}
